<?php
/**
 * Created by IntelliJ IDEA.
 * User: Administrator
 * Date: 2019/10/27
 * Time: 20:17
 */

class Solution_01 {

    /**
     * @param String $s
     * @return String
     */
    function longestPalindrome($s) {
        $max = 0;
        $resultStr = '';
        $strLen = strlen($s);
        if($strLen == 1){
            return $s;
        }
        for($i=1;$i<=$strLen;$i++){
            for($j=0;$j<=$strLen-$i;$j++){
                $tmpStr = substr($s,$j,$i);
                echo $tmpStr.PHP_EOL;
                if($this->isPalindrome($tmpStr)){
                    $max = $i;
                    $resultStr = $tmpStr;
                }
            }

        }
        return $resultStr;
    }

    function isPalindrome($str){
        $newStr = strrev($str);
        return $str == $newStr ? true :false;

    }
}
class Solution_02 {
    /**
     * @param String $s
     * @return String
     */
    function longestPalindrome($s) {
        $length = strlen($s);
        $str = $this->formatStr($s);


    }

    public function formatStr(string  $str){
        return "#".implode(str_split($str),"#")."#";
    }

}

$solution = new Solution_02();
$str = 'aa';
echo $solution->longestPalindrome($str);